package jee.boot.common.utils;

import com.github.pagehelper.util.StringUtil;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 邮件工具类
 * @author mskkingtake
 *
 */
public class MailUtil {
	
	/**
	 * 邮箱验证
	 * @param email
	 * @return
	 */
	public static boolean checkEmail(String email) {
	    boolean flag = false;
	    
	    try {
	    	if(StringUtil.isEmpty(email)) {
				flag = false;
			} else {
				String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
				Pattern regex = Pattern.compile(check);
				Matcher matcher = regex.matcher(email);
				flag = matcher.matches();
			}
	    } catch (Exception e) {
	        flag = false;
	    }
	    
	    return flag;
	}
}
